{% extends "main.html" %}
  {% block title %}Lucky{% endblock %}
 {% block name %}Lucky{% endblock %}
{% block table %}
    <table id="t1" class="table table-striped table-bordered" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>PostTime</th>
                <th>Code</th>
                <th>Name</th>
                <th>Publisher</th>
                <th>Director</th>
                <th>Manufacture</th>
                <th>Length</th>
                <th>Type</th>
                <th>Actress</th>
            </tr>
        </thead>
        <tbody>
        {% for i in data %}
          <tr>

                 <td>{{ i.postTime }}</td>
                 <td>{{ i.code }}</td>
                  <td>{{ i.movieName[0] }}</td>
                 <td>{{ i.publisher }}</td>
                  <td>{{ i.director }}</td>
                  <td>{{ i.manufacturer }}</td>
                  <td>{{ i.length }}</td>
                  <td>{{ i.type | join (',') }}</td>
                  <td>{{ i.actress | join(',') }}</td>

          </tr>
         {% endfor %}
        </tbody>
      </table>
{% endblock %}
{% block script %}
      <script type="text/javascript">
            $(document).ready(function() {
            $('#t1').DataTable({
                "dom": '<"toolbar">rtip',
                "paging":   true,
         "pageLength": 20,
          "destroy": true,
        "ordering": true,
        "info":     true,
                columnDefs: [
               { width: '10%', targets: 0 },
                { width: '10%', targets: 1},
                { width: '20%', targets: 2},
                { width: '7%', targets: 3},
                { width: '10%', targets: 4},
                { width: '10%', targets:5},
                { width: '8%', targets:6},
                { width: '17%', targets:7},
                { width: '10%', targets:8},{
                        "render": function(data) {
                    var result = "";
                            data = data.split(',');
                    for(var i=0;i<data.length;i++){
                        result  = result + '<a href="/type/'+data[i]+'">'+data[i]+'   '
                    }
                    return result
                },"targets": 7
                    },
                    {
                        "render": function(data, type, row) {
                    var result = "";
                            data = data.split(',');
                    for(var i=0;i<data.length;i++){
                        result  = result + '<a href="/actress/'+data[i]+'">'+data[i]+'   '
                    }
                    return result
                },"targets":8
                    }
        ]
            });
      var data = '{{ day }}';
           $("div.toolbar").html('<b>Last recommand: '+ data+'</b>');
              } );

   </script>

{% endblock %}